home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Frameworks / Hsoi's App Shell 1.0a4 / HAS Other Source / WASTE 1.3a4 Distribution / WASTE 1.3a4 / Source / WELongCoords.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-04  |  1.5 KB  |  74 lines  |  [TEXT/CWIE]

  1. /*
  2.  *    WELongCoords.c
  3.  *
  4.  *    WASTE PROJECT
  5.  *  Long Coordinates
  6.  *
  7.  *  Copyright (c) 1993-1997 Marco Piovanelli
  8.  *    All Rights Reserved
  9.  *
  10.  *  C port by Dan Crevier
  11.  *
  12.  */
  13.  
  14.  
  15. #include "WASTEIntf.h"
  16.  
  17. enum
  18. {
  19.     kQDMin = -32767L,
  20.     kQDMax = +32767L
  21. };
  22.  
  23. pascal SInt32 _WEPinInRange(SInt32 value, SInt32 rangeStart, SInt32 rangeEnd)
  24. {
  25.     return ((value > rangeEnd) ? rangeEnd : ((value < rangeStart) ? rangeStart : value));
  26. }
  27.  
  28. pascal void WELongPointToPoint(const LongPt *lp, Point *p)
  29. {
  30.     p->v = _WEPinInRange(lp->v, kQDMin, kQDMax);
  31.     p->h = _WEPinInRange(lp->h, kQDMin, kQDMax);
  32. }
  33.  
  34. pascal void WEPointToLongPoint(Point p, LongPt *lp)
  35. {
  36.     lp->v = p.v;
  37.     lp->h = p.h;
  38. }
  39.  
  40. pascal void WESetLongRect(LongRect *lr, SInt32 left, SInt32 top, SInt32 right, SInt32 bottom)
  41. {
  42.     lr->top    = top;
  43.     lr->left   = left;
  44.     lr->bottom = bottom;
  45.     lr->right  = right;
  46. }
  47.  
  48. pascal void WELongRectToRect(const LongRect *lr, Rect *r)
  49. {
  50.     WELongPointToPoint((const LongPt *) lr, (Point *) r);
  51.     WELongPointToPoint((const LongPt *) lr + 1, (Point *) r + 1);
  52. }
  53.  
  54. pascal void WERectToLongRect(const Rect *r, LongRect *lr)
  55. {
  56.     lr->top    = r->top;
  57.     lr->left   = r->left;
  58.     lr->bottom = r->bottom;
  59.     lr->right  = r->right;
  60. }
  61.  
  62. pascal void WEOffsetLongRect(LongRect *lr, SInt32 hOffset, SInt32 vOffset)
  63. {
  64.     lr->top    += vOffset;
  65.     lr->left   += hOffset;
  66.     lr->bottom += vOffset;
  67.     lr->right  += hOffset;
  68. }
  69.  
  70. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr)
  71. {
  72.     return ((lp->v >= lr->top) && (lp->h >= lr->left) && (lp->v < lr->bottom) && (lp->h < lr->right));
  73. }
  74.